//
// Decompiled by Jadx - 584ms
//
package fi;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.res.Resources;
import android.os.Environment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.n;
import cc.h;
import cc.k;
import cc.m;
import cc.o;
import cc.p;
import fg.b;
import fg.g;
import fg.i;
import fg.l;
import fg.q;
import fg.s;
import fg.u;
import fi.c;
import fj.d;
import fn.j;
import fn.y;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import r.e;
import r.f;

public final class w {
    public final Activity a;
    public u aa;
    public RecyclerView.h ab;
    public d ac;
    public c ae;
    public c af;
    public String ag;
    public String aj;
    public String ak;
    public boolean al;
    public int am;
    public int an;
    public int ao;
    public View ar;
    public g as;
    public boolean at;
    public final LayoutInflater b;
    public AlertDialog c;
    public Window d;
    public WindowManager.LayoutParams e;
    public Object f;
    public q g;
    public s h;
    public g i;
    public i j;
    public String k;
    public String l;
    public final String m;
    public String n;
    public String[] o;
    public fi.e q;
    public String r;
    public String s;
    public e v;
    public b w;
    public f x;
    public b y;
    public String z;
    public final ArrayList p = new ArrayList();
    public boolean t = true;
    public boolean u = true;
    public final ArrayList ad = new ArrayList();
    public int ah = 0;
    public int ai = 8388611;
    public boolean ap = true;
    public final ArrayList aq = new ArrayList();

    public w(Activity activity) {
        if (y.by.getBridge() != null) {
            j.z(activity);
        }
        String path = Environment.getExternalStorageDirectory().getPath();
        this.m = path;
        this.n = path;
        this.a = activity;
        this.b = LayoutInflater.from(activity);
    }

    public w(Activity activity, e eVar) {
        this.q = eVar;
        String path = Environment.getExternalStorageDirectory().getPath();
        this.m = path;
        this.n = path;
        this.a = activity;
        this.b = LayoutInflater.from(activity);
    }

    @SuppressLint({"NotifyDataSetChanged"})
    public final void au(String str, String str2) {
        b bVar = this.y;
        if (bVar != null && bVar.b != null) {
            for (int i = 0; i < this.y.b.size(); i++) {
                c cVar = (c) this.y.b.get(i);
                for (int i2 = 0; i2 < cVar.getList().size(); i2++) {
                    c.a aVar = (c.a) cVar.getList().get(i2);
                    if (aVar.getTitle() != null && aVar.getTitle().equals(str)) {
                        aVar.setDesc(str2);
                    }
                }
                try {
                    ((l) this.y.a.get(i)).notifyDataSetChanged();
                } catch (IndexOutOfBoundsException e) {
                    e.printStackTrace();
                }
            }
            return;
        }
        f fVar = new f(this.a);
        fVar.j();
        fVar.d = 80;
        fVar.l("dialogListAdapter is null");
    }

    @SuppressLint({"NotifyDataSetChanged"})
    public final void av(c.a aVar) {
        if (this.y == null) {
            f fVar = new f(this.a);
            fVar.j();
            fVar.d = 80;
            fVar.l("dialogListAdapter is null");
            return;
        }
        if (aVar != null) {
            for (int i = 0; i < this.y.b.size(); i++) {
                c cVar = (c) this.y.b.get(i);
                for (int i2 = 0; i2 < cVar.getList().size(); i2++) {
                    c.a aVar2 = (c.a) cVar.getList().get(i2);
                    if (!TextUtils.isEmpty(aVar2.getKey()) ? !(aVar2.getKey() == null || !aVar2.getKey().equals(aVar.getKey())) : !(aVar2.getTitle() == null || !aVar2.getTitle().equals(aVar.getTitle()))) {
                        aVar2.setSelected(aVar.isSelected());
                        aVar2.setTitle(aVar.getTitle());
                        aVar2.setDesc(aVar.getDesc());
                        aVar2.setArrow(aVar.isArrow());
                        aVar2.setSwitch(aVar.isSwitch());
                        aVar2.setHideArrow(aVar.isHideArrow());
                        aVar2.setRightText(aVar.getRightText());
                    }
                }
                try {
                    ((l) this.y.a.get(i)).notifyDataSetChanged();
                } catch (IndexOutOfBoundsException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public final void aw(boolean z) {
        i iVar;
        g fVar;
        View inflate = this.b.inflate(-2113142722, (ViewGroup) null, false);
        int i = 0x7f820063;
        if (((LinearLayout) androidx.constraintlayout.widget.i.cg(0x7f820063, inflate)) != null) {
            i = 0x7f820098;
            TextView textView = (TextView) androidx.constraintlayout.widget.i.cg(0x7f820098, inflate);
            if (textView != null) {
                i = 0x7f820099;
                TextView textView2 = (TextView) androidx.constraintlayout.widget.i.cg(0x7f820099, inflate);
                if (textView2 != null) {
                    i = 0x7f82009d;
                    ImageView imageView = (ImageView) androidx.constraintlayout.widget.i.cg(0x7f82009d, inflate);
                    if (imageView != null) {
                        i = 0x7f82009f;
                        TextView textView3 = (TextView) androidx.constraintlayout.widget.i.cg(0x7f82009f, inflate);
                        if (textView3 != null) {
                            i = 0x7f8200a0;
                            TextView textView4 = (TextView) androidx.constraintlayout.widget.i.cg(0x7f8200a0, inflate);
                            if (textView4 != null) {
                                LinearLayout linearLayout = (LinearLayout) inflate;
                                m mVar = new m(linearLayout, textView, textView2, imageView, textView3, textView4);
                                this.f = mVar;
                                bh(textView4, textView2, textView3, textView);
                                e.d(-2113535903, 25.0f, textView3);
                                e.d(-2113535903, 25.0f, textView);
                                Activity activity = this.a;
                                RecyclerView a = x.a(activity, e.a(activity, 10.0f), e.a(activity, 15.0f), e.a(activity, 10.0f), e.a(activity, 10.0f));
                                linearLayout.addView((View) a, 2);
                                ArrayList arrayList = this.ad;
                                if (z) {
                                    this.j = new i(arrayList, activity, this);
                                } else {
                                    this.i = new g(arrayList, activity, this);
                                }
                                r.g.v(imageView, -2113535886);
                                if (z) {
                                    iVar = this.j;
                                } else {
                                    iVar = this.i;
                                }
                                a.setAdapter(iVar);
                                textView3.setText("保存数据");
                                r rVar = new r(this, mVar, z);
                                textView.setOnClickListener(rVar);
                                textView3.setOnClickListener(rVar);
                                imageView.setOnClickListener(new s(this, z));
                                if (z) {
                                    fVar = new g(this.j);
                                } else {
                                    fVar = new f(this.i);
                                }
                                n nVar = new n(fVar);
                                RecyclerView recyclerView = nVar.t;
                                if (recyclerView != a) {
                                    n.b bVar = nVar.ab;
                                    if (recyclerView != null) {
                                        recyclerView.removeItemDecoration(nVar);
                                        nVar.t.removeOnItemTouchListener(bVar);
                                        nVar.t.removeOnChildAttachStateChangeListener(nVar);
                                        ArrayList arrayList2 = nVar.r;
                                        int size = arrayList2.size();
                                        while (true) {
                                            size--;
                                            if (size < 0) {
                                                break;
                                            }
                                            n.f fVar2 = (n.f) arrayList2.get(0);
                                            fVar2.j.cancel();
                                            nVar.o.getClass();
                                            n.d.c(fVar2.h);
                                        }
                                        arrayList2.clear();
                                        nVar.y = null;
                                        VelocityTracker velocityTracker = nVar.v;
                                        if (velocityTracker != null) {
                                            velocityTracker.recycle();
                                            nVar.v = null;
                                        }
                                        n.e eVar = nVar.aa;
                                        if (eVar != null) {
                                            eVar.a = false;
                                            nVar.aa = null;
                                        }
                                        if (nVar.z != null) {
                                            nVar.z = null;
                                        }
                                    }
                                    nVar.t = a;
                                    Resources resources = a.getResources();
                                    nVar.h = resources.getDimension(-2113470303);
                                    nVar.i = resources.getDimension(-2113470304);
                                    nVar.s = ViewConfiguration.get(nVar.t.getContext()).getScaledTouchSlop();
                                    nVar.t.addItemDecoration(nVar);
                                    nVar.t.addOnItemTouchListener(bVar);
                                    nVar.t.addOnChildAttachStateChangeListener(nVar);
                                    nVar.aa = new n.e(nVar);
                                    nVar.z = new androidx.core.view.f(nVar.t.getContext(), nVar.aa);
                                    return;
                                }
                                return;
                            }
                        }
                    }
                }
            }
        }
        throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i)));
    }

    public final File[] ax(File file) {
        String[] strArr = this.o;
        if (strArr == null) {
            return d.b(file.getPath());
        }
        int length = strArr.length;
        String path = file.getPath();
        return length == 0 ? d.c((String[]) null, path) : d.c(this.o, path);
    }

    public final void ay(b bVar) {
        this.aq.add(bVar.a);
        b bVar2 = this.y;
        if (bVar2 != null) {
            bVar2.notifyItemChanged(r0.size() - 1);
        }
    }

    public final void az() {
        AlertDialog alertDialog = this.c;
        if (alertDialog != null) {
            alertDialog.dismiss();
        }
    }

    public final c.a ba(String str) {
        b bVar = this.y;
        if (bVar != null) {
            Iterator it = bVar.b.iterator();
            while (it.hasNext()) {
                for (c.a aVar : ((c) it.next()).getList()) {
                    if (str.equals(aVar.getKey())) {
                        return aVar;
                    }
                }
            }
            return null;
        }
        return null;
    }

    public final void bb() {
        Object obj = this.f;
        if (obj != null) {
            if (obj instanceof k) {
                k kVar = (k) obj;
                bh(kVar.e, kVar.c, kVar.d, kVar.b);
            }
            Object obj2 = this.f;
            if (obj2 instanceof o) {
                o oVar = (o) obj2;
                bh(oVar.e, oVar.c, oVar.d, oVar.b);
            }
            Object obj3 = this.f;
            if (obj3 instanceof cc.i) {
                cc.i iVar = (cc.i) obj3;
                bh(iVar.f, iVar.c, iVar.e, iVar.b);
            }
            Object obj4 = this.f;
            if (obj4 instanceof h) {
                h hVar = (h) obj4;
                bh(hVar.f, hVar.c, hVar.e, hVar.b);
            }
            Object obj5 = this.f;
            if (obj5 instanceof cc.n) {
                cc.n nVar = (cc.n) obj5;
                bh(nVar.e, nVar.c, nVar.d, nVar.b);
            }
            Object obj6 = this.f;
            if (obj6 instanceof cc.l) {
                cc.l lVar = (cc.l) obj6;
                bh(lVar.e, lVar.c, lVar.d, lVar.b);
            }
            Object obj7 = this.f;
            if (obj7 instanceof m) {
                m mVar = (m) obj7;
                bh(mVar.e, mVar.c, mVar.d, mVar.b);
            }
            Object obj8 = this.f;
            if (obj8 instanceof cc.j) {
                cc.j jVar = (cc.j) obj8;
                bh(jVar.f, jVar.c, jVar.e, jVar.b);
            }
            Object obj9 = this.f;
            if (obj9 instanceof cc.q) {
                cc.q qVar = (cc.q) obj9;
                bh(qVar.e, qVar.c, qVar.d, qVar.b);
            }
            Object obj10 = this.f;
            if (obj10 instanceof p) {
                p pVar = (p) obj10;
                bh(pVar.e, pVar.c, pVar.d, pVar.b);
            }
        }
    }

    public final void bc(String str) {
        this.ak = str;
        bb();
    }

    public final void bd() {
        this.u = false;
        bb();
    }

    public final void be() {
        this.t = false;
        bb();
    }

    public final void bf(String str) {
        this.n = str;
        File file = new File(str);
        this.n = file.exists() ? file.isDirectory() ? file.getPath() : file.getParent() : this.m;
    }

    public final void bg(String str) {
        this.r = str;
        bb();
    }

    public final void bh(TextView textView, TextView textView2, TextView textView3, TextView textView4) {
        String str;
        String str2;
        if (TextUtils.isEmpty(this.aj)) {
            textView.setVisibility(View.GONE);
        }
        if (TextUtils.isEmpty(this.ak)) {
            textView2.setVisibility(View.GONE);
        }
        textView.setText(r.g.w(textView, this.aj));
        textView2.setText(r.g.w(textView2, this.ak));
        textView2.setGravity(this.ai);
        if (!this.t) {
            textView3.setVisibility(View.GONE);
        }
        if (!this.u) {
            textView4.setVisibility(View.GONE);
        }
        textView3.setEnabled(!this.al);
        textView4.setEnabled(true);
        if (TextUtils.isEmpty(this.r)) {
            str = "确定";
        } else {
            str = this.r;
        }
        textView3.setText(str);
        if (TextUtils.isEmpty(this.s)) {
            str2 = "取消";
        } else {
            str2 = this.s;
        }
        textView4.setText(str2);
    }

    public void bi(String str) {
        this.aj = str;
        bb();
    }

    public void bj(fi.e eVar) {
        if (eVar == fi.e.MESSAGE) {
            this.ai = 17;
        }
        this.q = eVar;
    }

    public final void bk() {
        Activity activity = this.a;
        if (activity == null) {
            return;
        }
        activity.runOnUiThread(new l(0, this));
    }
}
